batctl: Merge bugfixes from 2025.3 1139/head
authorSven Eckelmann <[email protected]>
Fri, 5 Sep 2025 14:19:21 +0000 (16:19 +0200)
committerSven Eckelmann <[email protected]>
Fri, 5 Sep 2025 14:19:50 +0000 (16:19 +0200)
* event: Fix direct parsing on hardif for set_hardif
* avoid memory leak in print_routing_algos

Signed-off-by: Sven Eckelmann <[email protected]>
batctl/Makefile
batctl/patches/0001-batctl-event-Fix-direct-parsing-on-hardif-for-set_ha.patch [new file with mode: 0644]
batctl/patches/0002-batctl-Avoid-memory-leak-in-print_routing_algos.patch [new file with mode: 0644]

index daee9dc41aa8ded1dd0223842bb2a3eeda8576f9..33843e1ebe3522b599ca5bc7e0b4f5405f499c8c 100644 (file)
@@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=batctl
 PKG_VERSION:=2024.3
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
diff --git a/batctl/patches/0001-batctl-event-Fix-direct-parsing-on-hardif-for-set_ha.patch b/batctl/patches/0001-batctl-event-Fix-direct-parsing-on-hardif-for-set_ha.patch
new file mode 100644 (file)
index 0000000..218296a
--- /dev/null
@@ -0,0 +1,27 @@
+From: Sven Eckelmann <[email protected]>
+Date: Sun, 3 Aug 2025 08:48:40 +0200
+Subject: batctl: event: Fix direct parsing on hardif for set_hardif
+
+The code to get the hard interface name for an even was accidentally
+checking for BATADV_ATTR_MESH_IFNAME instead of BATADV_ATTR_HARD_IFNAME. As
+result, the fallback code was always used when BATADV_ATTR_MESH_IFNAME
+would have not been available.
+
+Luckily, at the moment, BATADV_ATTR_HARD_IFNAME is always available when
+BATADV_ATTR_MESH_IFNAME is set BATADV_CMD_SET_HARDIF events.
+
+Fixes: d12322eeb361 ("batctl: event: Get ifname from netlink message")
+Signed-off-by: Sven Eckelmann <[email protected]>
+Origin: upstream, https://git.open-mesh.org/batctl.git/commit/?id=03288f4f3060591dbc33600b4e5f6371d6a9f4ff
+
+--- a/event.c
++++ b/event.c
+@@ -320,7 +320,7 @@ static void event_parse_set_hardif(struc
+                       return;
+       }
+-      if (attrs[BATADV_ATTR_MESH_IFNAME]) {
++      if (attrs[BATADV_ATTR_HARD_IFNAME]) {
+               hardif_name = nla_get_string(attrs[BATADV_ATTR_HARD_IFNAME]);
+       } else {
+               /* compatibility for Linux < 5.14/batman-adv < 2021.2 */
diff --git a/batctl/patches/0002-batctl-Avoid-memory-leak-in-print_routing_algos.patch b/batctl/patches/0002-batctl-Avoid-memory-leak-in-print_routing_algos.patch
new file mode 100644 (file)
index 0000000..904093f
--- /dev/null
@@ -0,0 +1,31 @@
+From: Sven Eckelmann <[email protected]>
+Date: Sun, 3 Aug 2025 08:49:12 +0200
+Subject: batctl: Avoid memory leak in print_routing_algos
+
+The opts.remaining_header string is alocated before the netlink callback
+object is created. But the callback object allocation can fail and the
+function will return in this case. To fix this, either the string buffer
+must be freed in this case or the opts.remaining_header allocation can
+simply be moved to a later point.
+
+Fixes: 0a14f8800dac ("batctl: Handle nl_cb_alloc errors")
+Signed-off-by: Sven Eckelmann <[email protected]>
+Origin: upstream, https://git.open-mesh.org/batctl.git/commit/?id=9363370cee11af3687ebef028f7c4518107ea424
+
+--- a/routing_algo.c
++++ b/routing_algo.c
+@@ -96,12 +96,12 @@ static int print_routing_algos(struct st
+       nl_send_auto_complete(state->sock, msg);
+       nlmsg_free(msg);
+-      opts.remaining_header = strdup("Available routing algorithms:\n");
+-
+       cb = nl_cb_alloc(NL_CB_DEFAULT);
+       if (!cb)
+               return -ENOMEM;
++      opts.remaining_header = strdup("Available routing algorithms:\n");
++
+       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, netlink_print_common_cb,
+                 &opts);
+       nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, netlink_stop_callback, NULL);